package org.lmj.dos.web.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.lmj.dos.common.bean.ServerResponse;
import org.lmj.dos.common.pojo.ProductImageEntity;
import org.lmj.dos.mapper.ProductImageMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;
import java.util.List;

@RestController
@RequestMapping("/productImage")
public class ProductImageController {
    @Autowired
    ProductImageMapper productImageMapper;

    @GetMapping("/getByProductId/{productId}")
    public ServerResponse productsList(@PathVariable("productId") Integer productId) throws IOException {
        QueryWrapper<ProductImageEntity> wrapper = new QueryWrapper<>();
        wrapper.lambda().eq(ProductImageEntity::getProductId,productId);
        List<ProductImageEntity> productImageEntityList = productImageMapper.selectList(wrapper);
        return ServerResponse.success(productImageEntityList);
    }
}
